 /* Author : Putri Andita R
 * 		    091511059
 * Proyek 4*/

package jtk.project4.fleet.field;

import java.awt.Dimension;

import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormLayout.Resize;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.control.RadioControl;
import nl.coderight.jazz.form.field.ComboField;
import nl.coderight.jazz.form.field.SelectField;
import nl.coderight.jazz.form.field.SpinnerField;
import nl.coderight.jazz.form.field.button.CheckButton;
import nl.coderight.jazz.form.field.button.RadioButton;



public class DateTrackingField extends GroupControl{
	
			private CheckButton dateTrackingButton;
			private RadioControl<String> radioControl;
			private RadioButton radioButton1;
			private RadioButton radioButton2;
			private SpinnerField recurringField;
			private ComboField fixedDateField;
			private SelectField dayField;
			private CheckButton enableAdvancedNotificationButton;
			private SpinnerField notifyField;
			private int i;
			
	public DateTrackingField(String bindID){
		setTitle("header.dateTracking");
			setBindID(bindID);
			createFields();
			createLayout();
	}
	
	private void createFields()
	{
		dateTrackingButton = new CheckButton("DateTracking");
		enableAdvancedNotificationButton = new CheckButton("EnableAdvancedNotification");
		recurringField = new SpinnerField<String>("domains","domain");
		for(i=-100;i<=100;i++)
		{
			recurringField.insert(i, true);
		}	
		recurringField.setPreferredSize(new Dimension(50, 20));
		
		notifyField = new SpinnerField<String>("domains","domain");
		for(i=-100;i<=100;i++)
		{
			notifyField.insert(i, true);
		}	
		notifyField.setPreferredSize(new Dimension(50, 20));
		
		radioControl = new RadioControl<String>("radio control");
		radioButton1 = new RadioButton("recurring: Every");
		radioButton2 = new RadioButton("Fixed Dates:");
		
		fixedDateField = new ComboField<String>("domains", "domain");
		fixedDateField.setPreferredSize(new Dimension(70, 20));
		
		dayField = new SelectField<String>("domains", "domain");
		dayField.setPreferredSize(new Dimension(70, 20));
		dayField.insert("days", true);
		dayField.insert("weeks", true);
		dayField.insert("months", true);
		dayField.insert("years", true);		
	}
	
	private void createLayout()
	{
		setLayout(new FormLayout())
		.addField(dateTrackingButton)
		.addRow()
		.addLabel("label.recurring: Every").addField(radioControl)
		.addField(recurringField)
		.addLabel("").addField(dayField,Resize.HORIZONTAL)
		.addField(enableAdvancedNotificationButton)
		.addRow()
		.addLabel("label.Fixed Dates:     ").addField(radioControl)
		.addField(fixedDateField, Resize.HORIZONTAL)
		.addLabel("               Notify").addField(notifyField).addLabel("days in advance                                                           ")
		
		;
	}
}
